//
// #001016 修改打印最长文本行的程序，使之可以打印任意长度的输入行的长度，
// 并尽可能多地打印文本
//
// Created by DongPan on 7/28/2022.
//
#include <stdio.h>

#define MAXLINE 1000        /*  maximum input line size */

int getline(char line[], int lim);

int main(void)
{
    int len;        /* current line length */
    int max;        /* maximum length seen so far */
    char line[MAXLINE];     /* longest line saved here */

    max = 0;
    while((len = getline(line, MAXLINE)) > 0) {

    }

    return 0;
}

/* getline: read a line into s, return length */
int getline(char s[], int lim)
{
    int c, i;
    for (i = 0; i < lim - 1 && (c = getchar()) !=EOF && c != '\n'; ++i) {
        s[i] = c;
    }
    if (c == '\n') {
        s[i] = c;
        ++i;
    }
    s[i] = '\0';
    return i;
}
